<template>
	<view class="tab-container">
		<view class="tab-item" v-for="(item, index) in tabs" :key="index" @click="tabsChange(index)">
			<view class="tab-text" :class="{'actived': current==index}">{{item}}</view>
			<view class="tab-line" :class="{'actived': current==index}" v-if="!hideLine"></view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"zy-tab",
		data() {
			return {
				// tabs: ['关于我', '我的经历', '我想要'],
				current: 0,
			};
		},
		props:{
			hideLine:{
				type: Boolean,
				default(){
					return false
				}
			},
			tabs:{
				type: Array,
				default(){
					return []
				}
			}
		},
		methods:{
			tabsChange(index) {
				this.current = index;
				this.$emit('change', index)
			},
			setIndex(index){
				this.current = index;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab-container {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 10rpx 0;
	
		.tab-item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			padding: 0 40rpx;
	
			.tab-text {
				font-size: 32rpx;
				color: #BDC8CC;
			}
	
			.tab-text.actived {
				font-size: 34rpx;
				font-weight: 500;
				color: #fff;
			}
	
			.tab-line {
				width: 68rpx;
				height: 4rpx;
				background-color: #3DFFDD;
				border-radius: 10rpx;
				margin-top: 10rpx;
				opacity: 0;
			}
	
			.tab-line.actived {
				opacity: 1;
			}
		}
	}
</style>